package com.dao.impl;

import com.bean.Order;
import com.dao.OrderDao;

import java.util.List;

public class OrderDaoImpl extends BaseDao implements OrderDao {

    @Override
    public int saveOrder(Order order) {

        String sql="insert into orders(`orderid`,`createtime`,`price`,`status`,`userid`)values(?,?,?,?,?)";
        return update(sql,order.getOrderid(),order.getCreatetime(),order.getPrice(),order.getStatus(),order.getUserid());
    }

    @Override
    public List<Order> queryByUserid(String userid) {
        String sql="select `orderid`,`createtime`,`price`,`status`,`userid` from orders where userid=?";
        return queryForList(Order.class,sql,userid);
    }

    @Override
    public List<Order> showMyOrdersa(String userid, int status) {
        String sql="select `orderid`,`createtime`,`price`,`status`,`userid` from orders where userid=? and status=?";
        return queryForList(Order.class,sql,userid,status);
    }
}
